package com.longge;

import java.util.Arrays;

public class MaxArea {

    public int maxArea(int h, int w, int[] horizontalCuts, int[] verticalCuts) {

        Arrays.sort(horizontalCuts);
        Arrays.sort(verticalCuts);

        int hw = 0;
        for (int i = 0; i <= horizontalCuts.length; i++) {
            if (i == 0) {
                hw = Math.max(horizontalCuts[i], hw);
            } else if (i < horizontalCuts.length) {
                hw = Math.max(horizontalCuts[i] - horizontalCuts[i - 1], hw);
            } else {
                hw = Math.max(h - horizontalCuts[i - 1], hw);
            }
        }

        int vw = 0;
        for (int i = 0; i <= verticalCuts.length; i++) {
            if (i == 0) {
                vw = Math.max(verticalCuts[i], vw);
            } else if (i < verticalCuts.length) {
                vw = Math.max(verticalCuts[i] - verticalCuts[i - 1], vw);
            } else {
                vw = Math.max(w - verticalCuts[i - 1], vw);
            }
        }

        return (int) (long) vw * hw % 1000000007;

    }

    public static void main(String[] args) {


        new MaxArea().maxArea(1000000000, 1000000000, new int[]{2}, new int[]{2});
    }

}
